home *** CD-ROM | disk | FTP | other *** search
/ Shocking The Web CD-ROM / SHOCK_CD.ISO / mac / Chapter Tutorials / CaseStudies / ch10.macromedia / brain.dcr / 00006.ls < prev    next >
Encoding:
Text File  |  1996-11-12  |  1.8 KB  |  74 lines

  1. global cQMOffset, cBound, gQMObjList, gAddressList, cStageH, cStageW, gReleaseTime, gReleaseAtTime, gTrackingList
  2.  
  3. on startMovie
  4.   set the randomSeed to the ticks
  5.   preLoadCast(25, 51)
  6.   setConstants()
  7.   setGlobals()
  8.   liberateQM(getAt(gQMObjList, 1))
  9. end
  10.  
  11. on setConstants
  12.   set stageH to the stageBottom - the stageTop
  13.   set stageW to the stageRight - the stageLeft
  14.   set leftEdge to 91
  15.   set topEdge to 36
  16.   set baseCastNum to the number of member "QM1"
  17.   set baseWidth to the width of cast baseCastNum / 2
  18.   set baseHeight to the height of cast baseCastNum / 2
  19.   set cBound to rect(leftEdge + baseWidth, topEdge + baseHeight, stageW - baseWidth, stageH - baseHeight)
  20.   set cQMOffset to 20
  21. end
  22.  
  23. on setGlobals
  24.   set gQMObjList to []
  25.   repeat with x = 1 to 10
  26.     add(gQMObjList, new(script "QMs Parent Script", x))
  27.     puppetSprite(x + cQMOffset, 1)
  28.   end repeat
  29.   set gReleaseTime to the ticks
  30.   set gTrackingList to [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  31.   set gReleaseAtTime to 500
  32. end
  33.  
  34. on animateQMs
  35.   repeat with t = 1 to 10
  36.     QMAction(getAt(gQMObjList, t))
  37.   end repeat
  38.   if (the ticks - gReleaseTime) > gReleaseAtTime then
  39.     repeat with x = 1 to count(gTrackingList)
  40.       set spriteToTry to x
  41.       set whichOne to getAt(gTrackingList, spriteToTry)
  42.       if not whichOne then
  43.         liberateQM(getAt(gQMObjList, spriteToTry))
  44.         exit repeat
  45.       end if
  46.     end repeat
  47.     set gReleaseTime to the ticks
  48.   end if
  49. end
  50.  
  51. on randomInRange low, high
  52.   return low + random(high - low + 1) - 1
  53. end
  54.  
  55. on moveQMs
  56.   repeat with t = 1 to count(gQMObjList)
  57.     animateQMs(getAt(gQMObjList, t))
  58.   end repeat
  59. end
  60.  
  61. on rollColors
  62.   repeat with x = 2 to 9
  63.     if rollOver(x) then
  64.       puppetSprite(x, 1)
  65.       set the ink of sprite x to 0
  66.       updateStage()
  67.       exit repeat
  68.     end if
  69.   end repeat
  70.   set the ink of sprite x to 5
  71.   puppetSprite(x, 0)
  72.   updateStage()
  73. end
  74.